home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 4
/
Amiga Tools 4.iso
/
tools
/
internet-tools
/
wirtenews
/
writenews2.www
next >
Wrap
Text File
|
1996-02-26
|
12KB
|
424 lines
/***********************************************************************
* WriteNews2 *
* *
* $VER: WriteNews2.3 *
* *
* When this script is added to Amiga Mosaic's Macro list, *
* it allows you to followup or post Newsitems to the news *
* group you are currently browsing in Amiga Mosaic, or email the *
* author of the news you are reading. *
* *
* Requires: *
* Amiga Mosaic 1.2 or higher (tested with 2.0AS225 version) *
* NNTPPost & SMTP from INetUtils (AS225 or Amitcp versions) *
* Rexxreqtools. Also useful if your editor won't open on *
* a defined public screen is Pubutils2 [aminet:utils/wb] *
* *
* Original script by Gary Gallagher *
* Modified by John Blyth to allow for editor switches *
* to insert { send / edit / list / abort } choice before exiting *
* clean up parsing & extraction of entries, refs and sendmail function *
***********************************************************************/
OPTIONS RESULTS
/* TRACE R */
/* Edit the following sections to set it up for your system */
/* check that you have set the required variables for */
/* email address, editor, editor switches, realname, .sig' file */
/**********************************************************************/
/* START OF SETTINGS SECTION */
REALNAME = 'Your real name'
/* ^^^^^^^^^^^^^^ put your real name here that you would *
* like to use in any greetings */
FROM = 'yourname@yourhost'
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ put your e-mail address here */
USEWB = ''
/* ^^^ SET TO yes to use workbench as the editor/multiview *
* screen, otherwise leave blank '' to use mosaic's pubscreen (which *
* could be workbench anyway) *
* This will be useful If your editor can not open on a public *
* screen. */
GREETING = 'On '||DATE()||' '||realname||' wrote:'||'0a'x
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
* your opening line for posting news.... *
* you might like to change this to a blank line eg greeting = '0a'x *
* if you don't like this one... feel free to change it */
SIGFILE = 'uulib:.signature'
/* ^^^^^^^^^^^^^^^^ put your sigfile location here *
* if you have multiple users on the machine you may be able to use an *
* $USER environmental variable, eg uulib:$USER.signature */
POSTMAIL = 'INET:c/SMTPpost -S'
POSTNEWS = 'INET:c/NNTPpost'
/* Set both of these commands to the news & mailposting options you *
* require (see the INETutils manual) make sure you get your path to *
* these utilities correct if you have not placed them in the default *
* locations. and any other settings required *
************************************************************************/
/* WE NOW NEED TO GET INFO ABOUT THE SCREEN AMOSAIC IS RUNNING ON */
'info screen'
SCREENNAME = result
SCREENNAME = Compress(SCREENNAME,'«»')
if (upper(SCREENNAME) = 'DEFAULT')|(UPPER(USEWB) = 'YES') then
SCREENNAME = 'Workbench'
screentag = "rt_pubscrname = "||SCREENNAME
/************************************************************************
* WE CAN NOW COMPLETE OUR SETTINGS */
EDITOR = 'C:Ed'
/* ^^^^^^ put your editor here */
EDITORFLAGS = 'window con:0/110/-1/380/Edit_News/screen'||SCREENNAME
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
* put any required editor flags here, eg startup macros or "-sticky" *
* commands to prevent your editor detaching from the originating shell *
* These are editor flags for ed, to make it open on mosaic's pubscreen *
* you'll need to adjust this line for the editor of your choice *
************************************************************************/
/* OK let's begin ............ */
if ~show(l, "rexxsupport.library") then
if ~addlib("rexxsupport.library", 0, -30) then
exit
if ~show(l, "rexxreqtools.library") then
if ~addlib("rexxreqtools.library", 0, -30) then
exit
if upper(usewb) = 'YES' then 'screen back'
/* write or followup a message */
from = from||' ('||realname||')'
call rtezrequest('Do you want to post a new message, follow one up or mail the author?',,
'_Post|_Follow up|_Mail|_Cancel',,'rtez_defaultresponse = 2 ' screentag)
mail = 0
select
when rtresult == 1 then
call WRITE
when rtresult == 2 then
call FOLLOW_UP
when rtresult == 3 then do
mail = 1
call FOLLOW_UP
end
otherwise call LEAVING
end
/* main loop to assemble news */
address command 'join t:NEWSHeader.temp t:NEWSbody.temp AS t:NEWSedit.temp'
glue = 'join t:NEWSedit.temp '||sigfile||' AS t:NEWSfinished.temp'
rtresult = 2
Do forever
if rtresult == 2 then do
address command editor||' t:NEWSedit.temp '||editorflags
end
call rtezrequest('Time to check before sending...Choose an action',,
'_Send|_Edit|_List|_Abort',,'rtez_defaultresponse = 1 ' screentag)
if rtresult == 3 then do
address command glue
address command 'sys:utilities/multiview t:NEWSfinished.temp pubscreen '||SCREENNAME
end
if rtresult == 2 then iterate
if rtresult == 1 then leave
if rtresult == 0 then call LEAVING
end
address command glue
if mail then do
address command postmail||' <t:NEWSfinished.temp'
call LEAVING
exit 0
end
address command postnews||' <t:NEWSfinished.temp'
call LEAVING
exit 0
/* functions begin here */
WRITE:
call MESSAGE
if open('outfile', 't:NEWSitem.temp', 'R') then
do until nextjunk == '<DT> Newsgroups:'
nextjunk = readln('outfile')
if LEFT(nextjunk,'16') = '<TITLE>Newsgroup' then leave
end
if LEFT(nextjunk,'16') = '<TITLE>Newsgroup' then do
parse value nextjunk with '<TITLE>Newsgroup ' NEWSgroups ','
end
else do
NEWSgroups = readln('outfile')
call NEWSGROUPS
end
/* Get Subject from user */
buffer = rtgetstring("", , "Enter subject:", , screentag)
if buffer == "" then do
call rtezrequest("You entered nothing!", "Bye",, screentag)
call LEAVING
end
else
NEWSsubject = strip(buffer)
open('Headfile', 't:NEWSHeader.temp', 'W')
From = 'From: '||from
writeln('Headfile',From)
ngroup = 'Newsgroups: '||NEWSgroups
writeln('Headfile',ngroup)
subject = 'Subject: '||NEWSsubject
writeln('Headfile',subject)
/* add blank.line at end of header */
writeln('Headfile','')
close('Headfile')
/* opening address */
open('infile', 't:NEWSbody.temp', 'W')
writeln('infile',greeting)
close('infile')
return
FOLLOW_UP:
/* fetch news item from AmigaMosaic */
call URL
call MESSAGE
/* parse NEWSitem for writer's address */
if open('outfile', 't:NEWSitem.temp', 'R') then
NEWSaddress = readln('outfile')
Junk = left(NEWSaddress,'9')
if junk ~= '<ADDRESS>' then
say 'Unable to recognise address line'
else
NEWSaddress = delstr(NEWSaddress,'1','9')
NEWSaddress = strip(NEWSaddress)
/* extract realname & email address */
marker = RIGHT(NEWSaddress,1)
SELECT
when marker = '>' then DO
place = INDEX(NEWSaddress,'<')
REALNAME = DELSTR(NEWSaddress,place)
MAILADDR = DELSTR(NEWSaddress,1,place)
MAILADDR = COMPRESS(MAILADDR,'<> ')
end
when marker = ')' then DO
place = INDEX(NEWSaddress,'(')
REALNAME = DELSTR(NEWSaddress,1,place)
REALNAME = COMPRESS(REALNAME,'()')
MAILADDR = COMPRESS(DELSTR(NEWSaddress,place))
end
otherwise REALNAME = NEWSaddress
END
/* skip next line of NEWSitem */
junk = readln('outfile')
/* Get subject from NEWSitem */
NEWSsubject = readln('outfile')
junk = left(NEWSsubject,'7')
if junk ~= '<TITLE>' then
say 'Unable to recognise subject line'
else
parse value NEWSsubject with '<TITLE> ' NEWSsubject '</TITLE>'
/* skip the next few lines of NEWSitem */
do until nextjunk == '<DT> Newsgroups:'
nextjunk = readln('outfile')
end
NEWSgroups = readln('outfile')
CALL NEWSGROUPS
/* pull out references */
nextjunk = readln('outfile')
if nextjunk == '<DT> References:' then do
NEWSrefs = ''
remain = readln('outfile')
junk = left(remain,'13')
if junk ~= '<DD> <A HREF=' then
do
say 'Unable to recognise NEWSrefs line'
end
else
do until remain = ''
parse value remain with '">' junk '</A>' remain
NEWSrefs = NEWSrefs||junk
end
NEWSrefs = NEWSrefs||' '||NEWSfrom
end
else NEWSrefs = NEWSfrom
do until left(nextjunk,'5') = '<PRE>'
nextjunk = readln('outfile')
end
call HEADER
/* body of letter */
open('infile', 't:NEWSbody.temp', 'W')
/* opening address */
greeting = 'In article '||NEWSfrom||' '||realname||' wrote:'||'0a'x
writeln('infile',greeting)
NEWSbody = nextjunk
NEWSbody = delstr(NEWSbody,'1','5')
do until NEWSbody == '</PRE>'
do until junk = ''
parse value NEWSbody with 1 leader '<A HREF="' junk '">' ref2 '</A>' remain
NEWSbody = leader||ref2||remain
end
NEWSbody = '>'||NEWSbody
writeln('infile',NEWSbody)
NEWSbody = readln('outfile')
end
close('infile')
close('outfile')
return
URL:
'get url'
NEWSfrom = result
/* prepare NEWSfrom line */
junk = left(NEWSfrom,'5')
junk = translate(junk)
if junk ~= 'NEWS:' then do
say 'Unable to recognise NEWSfrom line'
end
else
NEWSfrom = delstr(NEWSfrom,'1','5')
NEWSfrom = strip(NEWSfrom,'L','<')
NEWSfrom = '<'||NEWSfrom||'>'
return
MESSAGE:
'fetch source'
NewsDoc = result
open('infile', 't:NEWSitem.temp', 'W')
writech( 'infile', NewsDoc )
close('infile')
return
HEADER:
/* build news header */
open('Headfile', 't:NEWSHeader.temp', 'W')
From = 'From: '||from
writeln('Headfile',From)
SELECT
when mail then do
To = 'To: '||MAILADDR
writeln('Headfile',To)
end
otherwise do
ngroup = 'Newsgroups: '||NEWSgroups
writeln('Headfile',ngroup)
end
END
ToRe = left(NEWSsubject,'2')
ToRe = TRANSLATE(ToRe)
if ToRE ~= 'RE' then
subject = 'Subject: '||'Re:'||NEWSsubject
else
subject = 'Subject: '||NEWSsubject
writeln('Headfile',subject)
IF ~mail then do
if NEWSrefs ~= '' then do
NEWSrefs = 'References: '||NEWSrefs
writeln('Headfile',NEWSrefs)
end
end
/* add blank line at end of header */
writeln('Headfile','')
close('Headfile')
return
NEWSGROUPS:
junk = left(NEWSgroups,'13')
if junk ~= '<DD> <A HREF=' then
do
say 'Unable to recognise NEWSgroups line'
end
else do
nextjunk = ''
do until NEWSgroups = ''
parse value NEWSgroups with '">' junk '</A>' NEWSgroups
nextjunk = nextjunk||junk
end
end
NEWSgroups = compress(nextjunk)
return
LEAVING:
if exists('t:NEWSitem.temp') then
address command 'delete t:NEWSitem.temp'
if exists('t:NEWSHeader.temp') then
address command 'delete t:NEWSHeader.temp'
if exists('t:NEWSbody.temp') then
address command 'delete t:NEWSbody.temp'
if exists('t:NEWSedit.temp') then
address command 'delete t:NEWSedit.temp'
if exists('t:NEWSFinished.temp') then
address command 'delete t:NEWSFinished.temp'
/* if we used Workbench as our public screen this will return Amosaic */
/* to the front, or has no effect if Amosaic is already in front */
'screen front'
exit 0